import scrapy
import re
from scrapy import Request


class MiddleSpider(scrapy.Spider):
    name = 'middle'
    # allowed_domains = ['bai.com']
    start_urls = ['http://httpbin.org/ip']


    def start_requests(self):
        yield Request(url=self.start_urls[0], meta={'proxy': 'http://122.9.101.6:8888'}, dont_filter=True)
        # yield Request(url=self.start_urls[0], meta={'proxy': 'http://47.109.83.232:40001'}, dont_filter=True)



    def parse(self, response):
        page_text = response.text
        with open('./a.html', 'w', encoding='utf-8') as fp:
            fp.write(page_text)
            print(page_text)